package com.logictech.lims.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.Pagenation;
import com.logictech.lims.service.GlasswareTypeService;
import com.logictech.lims.service.LogService;
import com.logictech.lims.entity.GlasswareType;
import com.logictech.lims.dao.GlasswareTypeDao;

@Service("glasswareTypeService")
public class GlasswareTypeServiceImpl implements GlasswareTypeService {
	@Resource
	private GlasswareTypeDao glasswareTypeDao;
	
	@Resource
	private LogService logService;
	
	@Override
	public void doAdd(GlasswareType glasswareType) {
		glasswareTypeDao.add(glasswareType);
		logService.doAdd("1",glasswareType);
	}

	@Override
	public void doEdit(GlasswareType glasswareType) {
		glasswareTypeDao.update(glasswareType);
		logService.doAdd("2",glasswareType);
	}

	@Override
	public void doDelete(String id) {
		GlasswareType glasswareType  = glasswareTypeDao.get(id);
		logService.doAdd("3",glasswareType);
		glasswareType.setDeleteFlag("1");
		glasswareTypeDao.update(glasswareType);
	}

	@Override
	public GlasswareType queryById(String id) {
		GlasswareType glasswareType  = glasswareTypeDao.get(id);
		return glasswareType;
	}

	@Override
	public PageList<GlasswareType> queryPageList(
		PageQuery<GlasswareType> pageQuery) {
		PageList<GlasswareType> result = new PageList<GlasswareType>();
		Integer itemCount = glasswareTypeDao.count(pageQuery);
		List<GlasswareType> list = glasswareTypeDao.queryPageList(pageQuery,itemCount);
		Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
		result.setPagenation(pagenation);
		result.setValues(list);
		return result;
	}

	@Override
	public List<GlasswareType> querySizeList(String type) {
		return glasswareTypeDao.querySizeList(type);
	}
	
}
